/*
 * myport.h
 *
 *  Created on: 2010-8-20
 *      Author: Administrator
 */

#ifndef MYPORT_H_
#define MYPORT_H_

#include <stdlib.h>

#ifndef nsnull
#define nsnull 0
#endif
#ifndef nsresult
#define nsresult long
#endif

#ifndef PR_Malloc
#define PR_Malloc malloc
#endif
#ifndef PR_FREEIF
#define PR_FREEIF free
#endif

#define 	NS_OK   0
#define 	NS_ERROR_BASE   ((nsresult) 0xC1F30000)
#define 	NS_ERROR_NOT_INITIALIZED   (NS_ERROR_BASE + 1)
#define 	NS_ERROR_ALREADY_INITIALIZED   (NS_ERROR_BASE + 2)
#define 	NS_ERROR_NOT_IMPLEMENTED   ((nsresult) 0x80004001L)
#define 	NS_NOINTERFACE   ((nsresult) 0x80004002L)
#define 	NS_ERROR_NO_INTERFACE   NS_NOINTERFACE
#define 	NS_ERROR_INVALID_POINTER   ((nsresult) 0x80004003L)
#define 	NS_ERROR_NULL_POINTER   NS_ERROR_INVALID_POINTER
#define 	NS_ERROR_ABORT   ((nsresult) 0x80004004L)
#define 	NS_ERROR_FAILURE   ((nsresult) 0x80004005L)
#define 	NS_ERROR_UNEXPECTED   ((nsresult) 0x8000ffffL)
#define 	NS_ERROR_OUT_OF_MEMORY   ((nsresult) 0x8007000eL)
#define 	NS_ERROR_ILLEGAL_VALUE   ((nsresult) 0x80070057L)
#define 	NS_ERROR_INVALID_ARG   NS_ERROR_ILLEGAL_VALUE
#define 	NS_ERROR_NO_AGGREGATION   ((nsresult) 0x80040110L)
#define 	NS_ERROR_NOT_AVAILABLE   ((nsresult) 0x80040111L)
#define 	NS_ERROR_FACTORY_NOT_REGISTERED   ((nsresult) 0x80040154L)
#define 	NS_ERROR_FACTORY_REGISTER_AGAIN   ((nsresult) 0x80040155L)
#define 	NS_ERROR_FACTORY_NOT_LOADED   ((nsresult) 0x800401f8L)
#define 	NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT   (NS_ERROR_BASE + 0x101)
#define 	NS_ERROR_FACTORY_EXISTS   (NS_ERROR_BASE + 0x100)
#define 	NS_ERROR_PROXY_INVALID_IN_PARAMETER   ((nsresult) 0x80010010L)
#define 	NS_ERROR_PROXY_INVALID_OUT_PARAMETER   ((nsresult) 0x80010011L)

#define 	NS_LIKELY(x)   (!!(x))
#define 	NS_UNLIKELY(x)   (!!(x))

#define 	NS_FAILED(_nsresult)   (NS_UNLIKELY((_nsresult) & 0x80000000))
#define 	NS_SUCCEEDED(_nsresult)   (NS_LIKELY(!((_nsresult) & 0x80000000)))

#endif /* MYPORT_H_ */
